<template>
  <div class="login">
    <!-- 图片 -->
    <div class="login_left"><img src="@/assets/img/login.jpg" alt=""></div>
    <!-- 登录输入框 -->
    <div class="login_right">
      <div class="title_name">
        <h2>GTAV有限公司</h2>
      </div>
      <div>
        <el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm" size="medium" class="demo-ruleForm">
          <el-form-item prop="account">
            <el-input v-model="ruleForm.account" placeholder="账号" autocomplete="off">
              <i slot="prefix" class="el-input__icon el-icon-user"></i>
            </el-input>
          </el-form-item>
          <el-form-item prop="password">
            <el-input v-model="ruleForm.password" show-password placeholder="密码" autocomplete="off">
              <i slot="prefix" class="el-input__icon el-icon-lock"></i>
            </el-input>
          </el-form-item>
          <el-form-item>
            <el-button class="login_btn" type="primary" v-loading.fullscreen.lock="fullscreenLoading" @click="submitForm('ruleForm')">登 录</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
import * as api from '@/api/login'
export default {
  name: 'Login',
  data() {
    return {
      ruleForm: {
        account: '',
        password: ''
      },
      rules: {},
      fullscreenLoading: false
    }
  },
  methods: {
    submitForm() {
      api.login({}).then(res => {
        this.fullscreenLoading = true
        if (res == '登录成功') {
          setTimeout(() => {
            this.fullscreenLoading = false
            this.$router.push('/')
          }, 5000)
        }
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.login{
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 1000px;
  .login_left{
    height: 100vh;
    min-height: 750px;
   img{
    width:100%;
    height: 100%;
   }
  }
  .login_right{
    position: absolute;
    top: 0;
    right: 0;
    width: 350px;
    height: 100vh;
    min-height: 750px;
    background-color: #fff;
    opacity: 0.8;
    box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
    padding-top: calc(100vh /2 - 30px);
    .title_name {
      width: 100%;
      height: 30px;
      text-align: center;
    }
    div:nth-child(2){
      padding:0 calc(100% - 330px);
      text-align: center;
      .login_btn{
        width: 100%;
      }
    }
  }
}
</style>
